package com.zqxq.lottery.api.controller;

import com.zqxq.common.constant.Result;
import com.zqxq.common.enums.CodeEnum;
import com.zqxq.lottery.api.feign.LotteryServerFeignClient;
import com.zqxq.lottery.common.utils.CommonUtil;
import com.zqxq.lottery.entity.bo.user.UserCashBO;
import com.zqxq.lottery.entity.vo.expert.CommissionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(value = "跟单接口",tags = "跟单接口")
@RestController
@Slf4j
@RequestMapping(value = "/expert", produces = "application/json")
public class ExpertController {

    @Autowired
    private LotteryServerFeignClient lotteryServerFeignClient;

    /**
     * 作者:    
     * 创建时间: 2018年8月3日下午13:59:38
     * 描述:    跟单-专家认证
     * 备注:
     *
     * @param user_id 用户编号
     * @return
     */
    @ApiOperation("跟单-专家认证")
    @PostMapping("/expertAuth")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "user_id", value = "用户编号", paramType = "query", dataType = "Long", required = true, defaultValue = ""),
            @ApiImplicitParam(name = "nick", value = "昵称", paramType = "query", dataType = "String", required = false, defaultValue = ""),
            @ApiImplicitParam(name = "head_portrait", value = "头像地址", paramType = "query", dataType = "String", required = false, defaultValue = ""),
            @ApiImplicitParam(name = "introduce", value = "介绍", paramType = "query", dataType = "String", required = false, defaultValue = "")
    })
    public Result<?> expertAuth(Long user_id,String nick,String head_portrait,String introduce) {
        if (CommonUtil.isEmpty(user_id)) {
            return new Result<>(CodeEnum.FAIL.getCode(), "用户编号不能为空");
        }
        Result<?> result = lotteryServerFeignClient.expertAuth(user_id,nick,head_portrait,introduce);
        return result;
    }

    /**
     * 作者:
     * 创建时间: 2018年8月3日下午13:59:38
     * 描述: 跟单-关注专家
     * 备注:
     *
     * @param user_id  专家编号
     * @param fans_id 粉丝编号
     * @param status 状态(0:取消关注,1:关注)
     * @return
     */
    @ApiOperation("跟单-关注专家")
    @PostMapping("/follow")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "user_id", value = "用户编号", paramType = "query", dataType = "Long", required = true, defaultValue = ""),
            @ApiImplicitParam(name = "fans_id", value = "粉丝编号", paramType = "query", dataType = "Long", required = true, defaultValue = ""),
            @ApiImplicitParam(name = "status", value = "状态(0:取消关注,1:关注)", paramType = "query", dataType = "Integer", required = true, defaultValue = "")
    })
    public Result<?> follow(Long user_id,Long fans_id,Integer status) {
        if (CommonUtil.isEmpty(user_id) || user_id.intValue() == 0) {
            return new Result<>(CodeEnum.FAIL.getCode(), "用户编号不能为空");
        }
        if (CommonUtil.isEmpty(fans_id) || fans_id.intValue() == 0) {
            return new Result<>(CodeEnum.FAIL.getCode(), "粉丝编号不能为空");
        }
        if (CommonUtil.isEmpty(status)) {
            return new Result<>(CodeEnum.FAIL.getCode(), "状态不能为空");
        }
        return lotteryServerFeignClient.follow(user_id, fans_id, status);
    }

    /**
     * 作者:
     * 创建时间: 2018年8月3日下午13:59:38
     * 描述: 跟单-我的佣金-流水记录
     * 备注:
     * @param search
     * @return
     */
    @ApiOperation(value = "跟单-我的佣金-流水记录", notes="跟单-我的佣金-流水记录")
    @PostMapping(value="/commission/page")
    public Result queryUserCashPage(UserCashBO search){
        return lotteryServerFeignClient.queryUserCashCommissionPage(search);
    }

    /**
     * 作者:
     * 创建时间: 2018年8月3日下午13:59:38
     * 描述: 跟单-我的佣金信息
     * 备注:
     * @param user_id 用户编号
     * @return
     */
    @ApiOperation(value = "跟单-我的佣金信息", notes="跟单-我的佣金信息")
    @PostMapping(value="/commissionInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "user_id", value = "用户编号", paramType = "query", dataType = "Long", required = true, defaultValue = "132773525365850113")
    })
    public Result<CommissionVO> commissionInfo(Long user_id){
        if(CommonUtil.isEmpty(user_id) || user_id.intValue() == 0){
            return new Result<>(CodeEnum.FAIL.getCode(), "用户编号不能为空");
        }
        return lotteryServerFeignClient.commissionInfo(user_id);
    }

    /**
     * 作者:
     * 创建时间: 2018年8月3日下午13:59:38
     * 描述: 跟单-查询专家信息
     * 备注:
     * @param user_id 用户编号
     * @return
     */
    @ApiOperation(value = "跟单-查询专家信息", notes="跟单-查询专家信息")
    @PostMapping(value="/getExpertInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "user_id", value = "用户编号", paramType = "query", dataType = "Long", required = true, defaultValue = "132773525365850113")
    })
    public Result<CommissionVO> getExpertInfo(Long user_id){
        if(CommonUtil.isEmpty(user_id) || user_id.intValue() == 0){
            return new Result<>(CodeEnum.FAIL.getCode(), "用户编号不能为空");
        }
        return lotteryServerFeignClient.getExpertInfo(user_id);
    }
}
